<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="toTop" content="true">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" href="./Public/Home/css/gwc.css" />
<script type="text/javascript">
	var total = "{{$_SESSION['cart']['total']}}";
	var allnum = "{{$_SESSION['cart']['total_rows']}}";
</script>
<!--头部公用部分载入-->
{{include file="VIEW_PATH/Common/header.php"}}
<script type="text/javascript">
				$(function(){
				//加事件
				$('.jia').click(function(){
					var x=$(this).index('.jia');
					//用class点击获得
					var num=$(this).next('[name=num]').val();
					num=parseInt(num)+1;
		            $(this).next('[name=num]').val(num);
					var sid=$(this).siblings('[name=sid]').val();
//					alert(sid);
					//发送异步
					$.ajax({
						type:"post",
//						请求地址
						url:"{{U('Cart/edit',array('cmid'=>$_GET['cmid']))}}",
						data:{
							sid:sid,
							num:num
						},
						dataType:'json',
						success:function(data){
                            var jiage=$('[name=jiage]').eq(x).val();
							var price=num*jiage;
							$('.top-up').eq(x).find('.price').html(price);
						}
					});
				})
			})
		</script>
</script>
<script type="text/javascript">
				$(function(){
				//减事件
				$('.jian').click(function(){
					var x=$(this).index('.jian');
					//用class点击获得
					var num=$(this).siblings('[name=num]').val();
					if(num>1){
					  num=parseInt(num)-1;
					}
//                  if(num==1){$('.jian').unbind("click");}
		            $(this).siblings('[name=num]').val(num);
					var sid=$(this).siblings('[name=sid]').val();
//					alert(num);
					//发送异步
					$.ajax({
						type:"post",
//						请求地址
						url:"{{U('Cart/edit',array('cmid'=>$_GET['cmid']))}}",
						data:{
							sid:sid,
							num:num
						},
						dataType:'json',
						success:function(data){
//							获得隐藏域的价格
							var jiage=$('[name=jiage]').eq(x).val();
//							获得jian之后价格
							var price=num*jiage;
//							抓取当前第x的价格付一个新价格
							$('.top-up').eq(x).find('.price').html(price);
						}
					});
				})
			})
		</script>
</script>
<!--内容区域开始-->
<div id="content-title">
	<h1>我的购物车</h1>
</div>
<div id="content-all">
	<span>全部商品（0）</span>
</div>
{{if value="empty($data['goods'])"}}
<div id="kkry">
	<a href="{{U('Index/index')}}"><img src="./Public/Home/img/ggwc.png"/></a>
</div>
{{else}}
<form action="" method="post">
<table id="table">
   <thead>
   	<tr>
   		<th class="qx">
   			<input class="checkboxall" type="checkbox"/>&nbsp;&nbsp;全选
   		</th>
   		<th class="info">
   			商品信息
   		</th>
   		<th class="pr">
   			单价（元）
   		</th>
   		<th class="co">
   			数量
   		</th>
   		<th class="am">
   			小计（元）
   		</th>
   		<th class="op">
   			操作
   		</th>
   	</tr>
   	{{foreach from="$data['goods']" key="$k" value="$v"}}
   	<tbody>
   		<tr class="top">
   		</tr>
   		<tr class="top-up">
   			<td class="up-1">
   				<input type="checkbox" name="shop" class="shop"  value="" />
   			</td>
   			<td class="up-2">
                <a href=""><img src="{{$v['photo']}}"/></a>
   			</td>
   			<td class="up-3">
                <a href="">{{$v['name']}}</a>
                {{foreach from="$v['options']" key="$kk" value="$vv"}}
                <p><span>{{$kk}}：{{$vv}}</span></p>
                {{endforeach}}
   			</td>
   			<td class="up-4">
                <span>{{$v['price']}}</span>
   			</td>
   			<td class="up-5">
   				<div>
   					<input type="hidden" name="sid"  value="{{$k}}" />
   					<input type="hidden" name="jiage" value="{{$v['price']}}" />
   					<span class="jia">+</span>
   					<input type="text" value="{{$v['num']}}" class="allnum" name="num" />
   					<span class="jian">-</span>
   				</div>
   			</td>
   			<td class="up-6">
                <span class="price">{{$v['price']*$v['num']}}</span>
   			</td>
   			<td class="up-7">
                <a href="{{U('del',array('id'=>$k))}}">删除</a>
   			</td>
   		</tr>
   	</tbody>
   	{{endforeach}}
   </thead>
</table>

<div id="settle">
	<span class="settle-1">
		 <input type="checkbox" class="checkboxall" value="" />&nbsp;&nbsp;全选
		 <a href="javascript:;">删除选中商品</a> 
		 <a href="javascript:;">删除失效商品</a>
	</span>
	
	<div class="yxsp jiesuan">
		<div class="jsss">
			<a href="javascript:;" id="jiesuan" style="text-decoration: none;  color: #FFFFFF;">结&nbsp;&nbsp;算</a>
		</div>	
	</div>
	<div class="yxsp allprice">
		合计（不含运费）：<span>￥0</span>
	</div>
	<div class="yxsp allyxsp">
		已选商品：<span>&nbsp;&nbsp;0&nbsp;&nbsp;</span>件
	</div>
</div>
<!--内容区域结束-->
</form>
<script type="text/javascript">
	$('#jiesuan').click(function(){
//		$('form').submit();
//      获得跳转到订单页页面地址
		var dizhi="{{U('Order/index')}}";
		var sid='';
//		循环判断复选框是否选择抓隐藏$k值
		$.each($('.shop:checked'),function(){
			sid+=$(this).parents('tbody').find('[name=sid]').val()+',';
		})
//		判断是否选择商品，选中提交
	    if(sid){
	    	$(this).attr('href',dizhi+'&sids='+sid);
	    }
	})
</script>
{{endif}}
<div style="clear: both;"></div>
<!--调用尾部公用-->
{{include file="VIEW_PATH/Common/end.php"}}
</body>
</html>
